#ifndef VFORMATTOOLBAR_H
#define VFORMATTOOLBAR_H


//////////////////////////////////////////////////////////////////////////
// VFormatToolBar
class VAbstractControl;

class VFormatToolbarHelper : public QObject
{
	Q_OBJECT

public:
	VFormatToolbarHelper(QWidget* toolbarParent, QObject *parent=0);
	~VFormatToolbarHelper();

public:
	QToolBar* toolbar() const { return tb; }

public slots:
	void slotControlGotFocus(VAbstractControl* c);
	void slotControlLostFocus(VAbstractControl*);

private slots:
	void textBold();
	void textUnderline();
	void textItalic();
	void textFamily(const QString &f);
	void textSize(const QString &p);
	void textStyle(int styleIndex);
	void textColor();
	void textAlign(QAction *a);
	void currentCharFormatChanged(const QTextCharFormat &format);
	void cursorPositionChanged();

private:
	void setupTextActions();

	void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
	void fontChanged(const QFont &f);
	void colorChanged(const QColor &c);
	void alignmentChanged(Qt::Alignment a);

private:
	QAction 
		*actionTextBold,
		*actionTextUnderline,
		*actionTextItalic,
		*actionTextColor,
		*actionAlignLeft,
		*actionAlignCenter,
		*actionAlignRight,
		*actionAlignJustify;

	QComboBox *comboStyle;
	QFontComboBox *comboFont;
	QComboBox *comboSize;

private:
	QToolBar* tb;
	QWidget* m_toolbarParent;
	VMultilineEdit* textEdit;
	VAbstractControl* m_curControl;
};

#endif // VFORMATTOOLBAR_H
